#ifndef TWI_HPP
#define TWI_HPP

#include <cstdint>
#include <cstddef>

class TWIMaster {
public:
    enum class Event : unsigned int {
        WriteComplete,
        ReadComplete,
        ErrorOccurred,
    };

public:
    virtual ~TWIMaster() = default;

    virtual bool open(void) = 0;
    virtual bool close(void) = 0;

    virtual size_t read(void *buffer,size_t size) = 0;
    virtual size_t write(const void *buffer,size_t size) = 0;

    virtual bool setPreempt(bool preempt) = 0;

    virtual bool setAddressWidth(unsigned int address_width) = 0;
    virtual unsigned int getAddressWidth(void) = 0;

    virtual bool addEventCallback(Event event,void (*callback)(void)) = 0;
    virtual bool removeEventCallback(Event event);

    virtual bool setTimeout(uint32_t timeout_ms) = 0;
    virtual uint32_t getTimeout(void) const = 0;

    virtual int getErrorNumber(void) = 0;
    
public:
    static const uint32_t TIMEOUT_BLOCKING = 0x80000000;
};

class TWIDevice {

};

#endif